package com.zzl.study.auth.controller;

import com.zzl.study.auth.api.ProviderApi;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: zhangzl
 * @date: 2023/12/14 19:32
 * @version: 1.0
 * @description: 服务消费者Controller
 */
@Slf4j
@RestController
@RequestMapping("/consumer")
public class ConsumerController {

    @Resource
    private ProviderApi providerApi;

    /**
     * 打招呼
     *
     * @param name 姓名
     * @return 打招呼
     */
    @GetMapping("/hello")
    public String hello(@RequestParam("name") String name, HttpServletRequest request) {
        String authorization = request.getHeader("Authorization");
        log.info("authorization = {}" , authorization);
        return this.providerApi.hello(name);
    }

}
